package com.c.yinyuezhushou.Fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.c.yinyuezhushou.Adapter.MusicRecAdapter;
import com.c.yinyuezhushou.Interface.MyInterface;
import com.c.yinyuezhushou.MRetrofit.MusicItem;
import com.c.yinyuezhushou.MyApplication;
import com.c.yinyuezhushou.OnScrollListener.MusicRecOnScrollListener;
import com.c.yinyuezhushou.R;
import com.c.yinyuezhushou.Ui.ListActivity;

import java.util.List;

public class LoveHistoryFragment extends Fragment {
    private View rootView;
    private List<MusicItem> list;
    private MyInterface myInterface;

    public LoveHistoryFragment(List<MusicItem> list, MyInterface myInterface){
        this.list = list;
        this.myInterface = myInterface;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        rootView = inflater.inflate(R.layout.fragment_lovehistory, container, false);

        RecyclerView recyclerView = rootView.findViewById(R.id.fl_rec);

        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
        recyclerView.setLayoutManager(linearLayoutManager);

        MyApplication myApplication = (MyApplication) getActivity().getApplicationContext();

        ListActivity listActivity = new ListActivity();
        if (list!=null){
            recyclerView.setAdapter(new MusicRecAdapter(list,myApplication.getMusicService(),getFragmentManager(),myInterface));
        }
        return rootView;
    }
}
